/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/* vim:set et sts=4: */
/* IBust - IBus with Traditional interface
 * Copyright(c) 2013 Daniel Sun
 * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
 * Copyright (C) 2008-2010 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#if !defined (__IBUST_H_INSIDE__) && !defined (IBUST_COMPILATION)
#error "Only <ibust.h> can be included directly"
#endif

/**
 * SECTION: ibustfactory
 * @short_description: Factory for creating engine instances.
 * @title: IBustFactory
 * @stability: Stable
 *
 * An IBustFactory is an #IBustService that creates input method engine (IME) instance.
 * It provides CreateEngine remote method, which creates an IME instance by name,
 * and returns the D-Bus object path to IBust daemon.
 *
 * @see_also: #IBustEngine
 *
 */
#ifndef __IBUST_FACTORY_H_
#define __IBUST_FACTORY_H_

#include "ibustservice.h"
#include "ibustserializable.h"
#include "ibustengine.h"

G_BEGIN_DECLS

/*
 * Type macros.
 */

/* define GOBJECT macros */
/**
 * IBUST_TYPE_FACTORY:
 *
 * Return GType of IBust factory.
 */
#define IBUST_TYPE_FACTORY               \
    (ibust_factory_get_type ())

/**
 * IBUST_FACTORY:
 * @obj: An object which is subject to casting.
 *
 * Casts an IBUST_FACTORY or derived pointer into a (IBustFactory*) pointer.
 * Depending on the current debugging level, this function may invoke
 * certain runtime checks to identify invalid casts.
 */
#define IBUST_FACTORY(obj)               \
    (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUST_TYPE_FACTORY, IBustFactory))

/**
 * IBUST_FACTORY_CLASS:
 * @klass: A class to be casted.
 *
 * Casts a derived IBustFactoryClass structure into a IBustFactoryClass structure.
 */
#define IBUST_FACTORY_CLASS(klass)       \
    (G_TYPE_CHECK_CLASS_CAST ((klass), IBUST_TYPE_FACTORY, IBustFactoryClass))

/**
 * IBUST_IS_FACTORY:
 * @obj: Instance to check for being a IBUST_FACTORY.
 *
 * Checks whether a valid GTypeInstance pointer is of type IBUST_FACTORY.
 */
#define IBUST_IS_FACTORY(obj)            \
    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUST_TYPE_FACTORY))

/**
 * IBUST_IS_FACTORY_CLASS:
 * @klass: A class to be checked.
 *
 * Checks whether class "is a" valid IBustFactoryClass structure of type IBUST_FACTORY or derived.
 */
#define IBUST_IS_FACTORY_CLASS(klass)    \
    (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUST_TYPE_FACTORY))

/**
 * IBUST_FACTORY_GET_CLASS:
 * @obj: An object.
 *
 * Get the class of a given object and cast the class to IBustFactoryClass.
 */
#define IBUST_FACTORY_GET_CLASS(obj)     \
    (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUST_TYPE_FACTORY, IBustFactoryClass))

typedef struct _IBustFactory IBustFactory;
typedef struct _IBustFactoryClass IBustFactoryClass;
typedef struct _IBustFactoryPrivate IBustFactoryPrivate;

/**
 * IBustFactory:
 *
 * An opaque data type representing an IBustFactory.
 */
struct _IBustFactory {
    /*< private >*/
    IBustService parent;
    IBustFactoryPrivate *priv;

    /* instance members */
};

struct _IBustFactoryClass {
    /*< private >*/
    IBustServiceClass parent;

    /*< public >*/
    /* signals */
    IBustEngine *
                (* create_engine)
                                    (IBustFactory    *factory,
                                     const gchar    *engine_name);

    /*< private >*/
    /* padding */
    gpointer pdummy[7];
};

/**
 * ibust_factory_info_get_type:
 * @returns: GType of IBust factory information.
 *
 * Return GType of IBust factory information.
 */
GType            ibust_factory_get_type          (void);

/**
 * ibust_factory_new:
 * @connection: An GDBusConnection.
 * @returns: A newly allocated IBustFactory.
 *
 * New an IBustFactory.
 */
IBustFactory     *ibust_factory_new               (GDBusConnection *connection);

/**
 * ibust_factory_add_engine:
 * @factory: An IBustFactory.
 * @engine_name: Name of an engine.
 * @engine_type: GType of an engine.
 *
 * Add an engine to the factory.
 */
void             ibust_factory_add_engine        (IBustFactory    *factory,
                                                 const gchar    *engine_name,
                                                 GType           engine_type);

/**
 * ibust_factory_create_engine:
 * @factory: An #IBustFactory.
 * @engine_name: Name of an engine.
 * @returns: (transfer full): #IBustEngine with @engine_name.
 *
 * Create an #IBustEngine with @engine_name.
 */
IBustEngine      *ibust_factory_create_engine     (IBustFactory    *factory,
                                                 const gchar    *engine_name);

G_END_DECLS
#endif

